// import { Action } from '@remix-run/router'
import hanle from './index'
const defaultstore = {
    ...hanle.state
}
let reducer = (state = defaultstore, action: { type: string }) => {
    let newstate = JSON.parse(JSON.stringify(state))
    // switch (action.type) {
    //     case handlenum.add1:
    //         handlenum.actions[handlenum.add1](newstate,action)
    //         break;
    //     case handlenum.add2:
    //         handlenum.actions[handlenum.add2](newstate,action)
    //         break;
    //     default:
    //         break;
    // }
    // for (let key in store) {
    //     if (action.type===store.actionnames[key]) {
    //         store.actions[store.actionnames[key]](newstate,action)
    //     }
    for (let key in hanle.actions) {
        // store.actionnames[key]=key
        // store.actionnames=store.actionnames
      if (action.type===key) {
        hanle.actions[key](newstate,action)
        }
    }
    return newstate
}
export default reducer